"use strict";
cc._RF.push(module, 'fa63dVtRWxBJ5ZQPjTcs5YF', 'ResManager');
// scripts/ResManager.js

"use strict";

var t = require;
var e = module;
var o = exports;
Object.defineProperty(o, "__esModule", {
  value: !0
});

var i = function () {
  function t() {
    this.total = 0, this.now = 0, this.totalAb = 0, this.nowAb = 0, this.progressFunc = null, this.endFunc = null, this.abBunds = {};
  }

  return t.getInstance = function () {
    return null == this.Instance && (this.Instance = new t()), this.Instance;
  }, t.prototype.loadAssetsBundle = function (t, e) {
    var o = this;
    cc.assetManager.loadBundle(t, function (i, n) {
      o.abBunds[t] = null !== i ? null : n, e && e();
    });
  }, t.prototype.loadAssetsInAssetsBundle = function (t) {
    for (var e in t) {
      for (var o = t[e].urls, i = t[e].assetType, n = 0; n < o.length; n++) {
        this.loadRes(this.abBunds[e], o[n], i);
      }
    }
  }, t.prototype.loadRes = function (t, e) {
    var o = this;
    t.load(e, null, function (t) {
      o.now++, t ? cc.log("load Res" + e + "error:" + t) : cc.log("load Res" + e + "success"), o.progressFunc && o.progressFunc(o.now, o.total), o.now >= o.total && null !== o.endFunc && o.endFunc();
    });
  }, t.prototype.preloadResPkg = function (t, e, o) {
    var i = this;

    for (var n in this.total = 0, this.now = 0, this.totalAb = 0, this.nowAb = 0, this.progressFunc = e, this.endFunc = o, t) {
      this.totalAb++, this.total += t[n].urls.length;
    }

    for (var n in t) {
      this.loadAssetsBundle(n, function () {
        i.nowAb++, i.nowAb === i.totalAb && i.loadAssetsInAssetsBundle(t);
      });
    }
  }, t.prototype.getAsset = function (t, e) {
    var o = cc.assetManager.getBundle(t);
    return null === o ? (cc.error("[error]" + t + "AssetsBundle not loaded !!"), null) : o.get(e);
  }, t.Instance = null, t;
}();

o["default"] = i;

cc._RF.pop();